<?
die("Stopp!");

include("conf.inc.php");
include("functions.php");

set_time_limit(0);

dbConnect();

$sSql = "TRUNCATE TABLE  `tblAsiktstorget`";
mysql_query($sSql) or die(mysql_error());

$lines = file("Messages.txt");

foreach($lines as $line) {
	list($id, $medlemsIdTo, $medlemsIdFrom,	$body, $dateTime, $ny, $altNick, $deletedFrom, $deletedTo) = explode("\t", $line);
	
	$body = preg_replace('/<a href="(.*?)" target="_blank">(.*?)<\/a>/', '$1', $body);
	$body = strip_tags($body);
	$body = iconv("CP850", "ISO-8859-1", $body);
	$body = utf8_encode($body);
	$body = str_replace(array("'", '"'), array("\'", '\"'), $body);
	
	
	if($medlemsIdTo == 0) {
		$sSql = "INSERT INTO tblAsiktstorget SET
				medlemsId = '" . $medlemsIdFrom . "',
				dateTime = '" . $dateTime . "',
				body = '" . $body . "'";
		mysql_query($sSql) or die(mysql_error());
		echo($sSql . "\n\n");
	}
}

mysql_close();
?>